package com.uobgroup.ews.uam.core.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.uobgroup.ews.uam.core.dao.RoleSubTypeDao;
import com.uobgroup.ews.uam.core.domain.Reference;
import com.uobgroup.ews.uam.core.domain.RoleSubType;

@Service
@Transactional
public class RoleSubTypeServiceImpl implements RoleSubTypeService {
	
	@Autowired
	RoleSubTypeDao roleSubTypeDao;
	
	/*
    * Han Truong
    */
	
	public long countAllRoleSubType()
	{
	
		return roleSubTypeDao.count();
		
	}

	 public void deleteRoleSubType(RoleSubType roleSubType)
	 {
		 roleSubTypeDao.delete(roleSubType);		 
		 
	 }
	 
	 public RoleSubType findRoleSubType(Long id)
	 {
		 RoleSubType roleSubType = roleSubTypeDao.findOne(id);		 
		 return roleSubType;
		 
	 }

	 public List<RoleSubType> findAllRoleSubType()
	 {
		 return roleSubTypeDao.findAll();
		 
	 }
	 
	 public List<RoleSubType> findRoleSubTypeEntries(int firstResult, int maxResults)
	 {
		 return roleSubTypeDao.findAll(firstResult, maxResults);
	 }

	 public void saveRoleSubType(RoleSubType roleSubType)
	 {
		 roleSubTypeDao.save(roleSubType);
	 }

	 public RoleSubType updateRoleSubType(RoleSubType roleSubType)
	 {
		 return roleSubTypeDao.update(roleSubType);
		 
	 }

	 public List<RoleSubType> findByRoleTypeID(Long roleTypeID)
	 {
		return roleSubTypeDao.findByRoleTypeID(roleTypeID);
	 }
	 public Boolean CheckIsUse(Long roleSubTypeId)
	 {
		 return roleSubTypeDao.CheckIsUse(roleSubTypeId);
	 }
	 /**
	  * @author dongn
	  */
   @Override
   public long countRoleSubTypeThatHasRoleTypeReference(Reference roleType) {
      return roleSubTypeDao.countRoleSubTypeThatHasRoleTypeReference(roleType);
   }
	 
	
}